package com.liangzhong.message.http
{
	import com.adobe.crypto.MD5;
	import com.global.GlobalDef;
	
	import flash.external.ExternalInterface;
	
	import lz.controls.Alert;

	/**
	 * 与js 通讯接口
	 * @author lxh
	 * 
	 */	
	public class JsClient
	{
		public function JsClient()
		{
		}
		/**
		 * 邀请
		 * 
		 */		
		public static function inviteFriend():void
		{
			if(ExternalInterface.available)
			{
				ExternalInterface.call("app_invite");
			}
		}
		/**
		 * 
		 * 充值
		 * @param type
		 * 1 金币
		 * 2 点券
		 */		
		public static function recharge(type :int = 1):void
		{
			//Alert.show("删档测试期间，充值暂不开放！","",Alert.YES,GlobalDef.AlertContainer);
			//return;
			if(ExternalInterface.available)
			{
				ExternalInterface.call("app_recharge",type);
			}
		}
		/**
		 *返回首页 
		 * 
		 */		
		public static function toHomePage():void
		{
			if(ExternalInterface.available)
			{
				ExternalInterface.call("app_tohome");
			}
		}
		/**
		 *刷新页面 
		 */		
		public static function app_reload():void
		{
			if(ExternalInterface.available)
			{
				ExternalInterface.call("app_reload");
			}
		}
		/**
		 *访问朋友主页 
		 * 
		 */		
		public static function tofrdhome(username :String):void
		{
			if(ExternalInterface.available)
			{
				ExternalInterface.call("app_tofrdhome",username);
			}
		}
		/**
		 *分享 
		 * 
		 */		
		public static function app_tweet(msg :String,url :String):void
		{
			if(ExternalInterface.available)
			{
				ExternalInterface.call("app_tweet",msg,url);
			}
		}
		/**
		 * 分享 1
		 * @param cid
		 * @param title 标题
		 * @param summary 应用简介
		 * @param msg 分享内容
		 * @param url 图片
		 * @param button 操作区的文字类型 --1.进入应用； 2.领取奖励； 3. 获取能量； 4.帮助TA
		 *source
		 *  time=时间&sign=md5('lzkj'+time+'2013')
		 */		
		public static function app_sendStory(cid :int,
											 title:String,
											 summary:String,
											 msg :String,
											 url :String,
											 button:int):void
		{
			var date :Date = new Date();
			var time :Number = date.time;
			var sign :String = MD5.hash("lzkj" + time + "2013");
			var source :String = "time=" + time + "&sign=" + sign;
			if(ExternalInterface.available)
			{
				ExternalInterface.call("app_sendStory",cid,title,url,summary,msg,button,source);
			}
		}
		/**
		 *黄砖
		 * @param type 
		 * 1 开通黄钻
         * 2 开通年费黄钻
		 */		
		public static function app_tobemember(type :int):void
		{
			if(ExternalInterface.available)
			{
				ExternalInterface.call("app_tobemember",type);
			}
		}
		/**
		 * 
		 *buy prop
		 */		
		public static function app_recharge_goods(gid :int,num :int,uids :String = null):void
		{
			if(ExternalInterface.available)
			{
				ExternalInterface.call("app_recharge_goods",gid,num,uids);
			}
		}
	}
}